package com.chuanke.ckfamily.service.common.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.chuanke.ckfamily.dao.common.EquipmentDao;
import com.chuanke.ckfamily.dao.common.model.Equipment;
import com.chuanke.ckfamily.service.common.CacheService;
import com.chuanke.ckfamily.service.common.EquipmentService;
import com.weijie.core.BaseBiz;

@Service
@Transactional
public class EquipmentServiceImpl extends BaseBiz<Equipment, EquipmentDao> implements EquipmentService {

	@Autowired
	private CacheService cacheService;

	@Override
	public Equipment getEqupment(String imie) {
		Equipment equipment = (Equipment) cacheService.get(CacheService.KEY_PREFIX.equipment_ + imie);
		if (equipment == null) {
			equipment = baseDao.findByImie(imie);
			cacheService.set(CacheService.KEY_PREFIX.equipment_ + imie, equipment);
		}
		return equipment;
	}
}